package com.bw.a2301club

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.bw.a2301club.databinding.ActivityMainBinding
import com.bw.lib_common.utils.utils.LoggerUtils
import com.bw.lib_net.NetModule
import dagger.hilt.android.AndroidEntryPoint
import retrofit2.Retrofit
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
//    @Inject
//    lateinit var client: OkHttpClient

    @NetModule.MallRetrofit
    @Inject
    lateinit var retrofit:Retrofit
    companion object{
        const val TAG = "MainActivity"
    }
    private lateinit var activityMainBinding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        activityMainBinding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(activityMainBinding.root)

        activityMainBinding.url = "https://ts1.tc.mm.bing.net/th/id/OIP-C.pQHbME4JQQuYzjqG7nFaYAHaE7?w=264&h=211&c=8&rs=1&qlt=90&o=6&dpr=1.1&pid=3.1&rm=2"

    }

    fun toMain(view: View) {
        //测试hilt
        LoggerUtils.d(TAG, "hilt: "+retrofit)
//        ARouter.getInstance().build( "/main/MainActivity").navigation()
        //anr测试
//        Thread.sleep(10*1000)
        //崩溃测试
//        val a = 10/0
//        MathUtils.chu()
        //测试mmkv
//        AppMMKV.userAgreement = true //写入数据
//        LoggerUtils.d(TAG, AppMMKV.userAgreement.toString()) //读取数据
//
//
//        UserMMKV.token = "123456" //写入数据
//        LoggerUtils.d(TAG, UserMMKV.token)//读取数据
        //测试数据库
//        DBUtils.getDB().historyDao().insertAll(History(8,"标题1","内容1"),History(9,"标题2","内容2"))
//        DBUtils.getDB().historyDao().getAllHistory().forEach {
//            LoggerUtils.d(TAG,it.title+it.content)
//        }
        //测试glide
//        Glide.with(this)
//            .load("https://ts1.tc.mm.bing.net/th/id/OIP-C.pQHbME4JQQuYzjqG7nFaYAHaE7?w=264&h=211&c=8&rs=1&qlt=90&o=6&dpr=1.1&pid=3.1&rm=2")
//            .transform(CircleCrop())
//            .diskCacheStrategy(DiskCacheStrategy.DATA)
//            .into(iv)


//        GlideApp.with(this)
//            .load("https://ts1.tc.mm.bing.net/th/id/R-C.98411f1b4f70501fbfa652c4c2a63843?rik=BI5K%2bIqMmK3d5g&riu=http%3a%2f%2fimg.ewang.com%2f6c117a240949949b1c6c.jpg&ehk=g9TE7x8dPR2TpuAjguBK7KayNfHi0eI2GY%2bn7SEEzPE%3d&risl=&pid=ImgRaw&r=0")
//            .transform(CircleCrop())
//            .into(iv)
//        GlideApp.with(this)
//            .load("https://ts1.tc.mm.bing.net/th/id/OIP-C.pQHbME4JQQuYzjqG7nFaYAHaE7?w=264&h=211&c=8&rs=1&qlt=90&o=6&dpr=1.1&pid=3.1&rm=2")
//            .transform(CircleCrop())
//            .into(iv)
        //测试LinkedHashMap
        //16初始容量 加载因子0.75 当放13个时候扩容2倍   true:按照访问顺序排队
//        val map = LinkedHashMap<String,String>(16,0.75f,true)
//        map["11"] = "11"
//        map["12"] = "12"
//        map["13"] = "13"
//        map["14"] = "14"
//        map["15"] = "15"
//        map["16"] = "16"
//        map["17"] = "17"
//        map["18"] = "18"
//        map["19"] = "19"
//        LoggerUtils.d(TAG,map.toString())
//{11=11, 12=12, 13=13, 14=14, 15=15, 16=16, 17=17, 18=18, 19=19}
//        val value = map["14"]
//        val value2 = map["11"]
//        LoggerUtils.d(TAG,map.toString())
        //{12=12, 13=13, 15=15, 16=16, 17=17, 18=18, 19=19, 14=14, 11=11}
    }
}